package com.qingzhuge.entity;

import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.Column;
import javax.persistence.EntityListeners;
import javax.persistence.MappedSuperclass;
import java.io.Serializable;
import java.util.Date;

/**
 * @author : zero.xiao
 * @description : 简单的抽象基础类，未指定id类型，声明name,createTime属性，用于简单功能类
 * @date :2018/6/7 0007 上午 9:34
 * @modified : AuditingEntityListener,CreatedDate 自动设置时间监听器
 */
@Getter
@Setter
@EntityListeners(AuditingEntityListener.class)
@MappedSuperclass
public abstract class BaseBriefnessEntity<PK extends Serializable> extends BaseBean<PK> {
    private static final long serialVersionUID = 9021761868355096137L;

    public static final String FIELD_NAME = "name";
    @ApiModelProperty("名称，标题")
    /**名称，标题*/
    private String name;

    @ApiModelProperty("创建时间")
    /**创建时间*/
    @Column(updatable = false)
    @CreatedDate
    private Date createTime;


    public BaseBriefnessEntity() {
        super();
    }

    public BaseBriefnessEntity(String name) {
        this.name = name;
    }

    @Override
    public String toString() {
        return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
    }
}
